//
//  Person.m
//  OCExam
//
//  Created by dllo on 16/6/2.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "Person.h"

@implementation Person

-(instancetype)initWithName:(NSString *)name withSex:(NSString *)sex withPhone:(NSString *)phone withAge:(NSInteger)age{
    self = [super init];
    if (self) {
        self.name = name;
        self.sex = sex;
        self.phone = phone;
        self.age = age;
        //group为大写的姓名首字母
        self.group = [[name substringWithRange:NSMakeRange(0, 1)] uppercaseString];
    }
    return self;
}

+(instancetype)personWithName:(NSString *)name withSex:(NSString *)sex withPhone:(NSString *)phone withAge:(NSInteger)age{
    Person *person = [[Person alloc] initWithName:name withSex:sex withPhone:phone withAge:age];
    return [person autorelease];
}


- (NSString *)description
{
    return [NSString stringWithFormat:@"姓名:%@ 性别:%@ 年龄:%ld 电话:%@", self.name ,self.sex,self.age, self.phone];
}


@end
